﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Avatar.Model;
using AvatarHelper;

namespace Avatar.OnlinePayment
{
    public static class PaymentManager
    {
        /// <summary>
        /// 保存在线支付数字接口信息
        /// </summary>
        /// <param name="_interfaceName"></param>
        /// <param name="_bankSH"></param>
        /// <param name="_bankMS"></param>
        /// <param name="_open"></param>
        /// <returns></returns>
        public static bool InterfaceEdit(string _interfaceName, string _bankSH, string _bankMS, bool _open)
        {
            return DBHelper.Save<InterBank>(new InterBank(),
                b => b.BankName == _interfaceName,
                b => b.BankName == _interfaceName && b.BankSH == _bankSH && b.BankMS == _bankMS,
                delegate(InterBank _i)
                {
                    _i.BankName = _interfaceName;
                    _i.BankMS = _bankMS;
                    _i.BankSH = _bankSH;
                    _i.Passed = _open;
                },
                delegate(InterBank _i)
                {
                    _i.BankName = _interfaceName;
                    _i.BankMS = _bankMS;
                    _i.BankSH = _bankSH;
                    _i.Passed = _open;
                }, "保存在线支付数字接口信息出错:");
        }
        /// <summary>
        /// 获取在线支付接口列表
        /// </summary>
        /// <returns></returns>
        public static List<InterBank> GetInterfaceList()
        {
            return DBHelper.GetAll<InterBank>("获取在线支付接口列表出错:");
        }
        /// <summary>
        /// 获取在线支付接口
        /// </summary>
        /// <param name="_id"></param>
        /// <returns></returns>
        public static InterBank GetInterface(int _id)
        {
            return DBHelper.Get<InterBank>(b => b.ID == _id, "获取网银在线支付接口数据出错:");
        }
    }
}
